package com.zygh.lz.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zygh.lz.entity.Sign;
import com.zygh.lz.entity.signfile.SignStatistics;
import com.zygh.lz.vo.ExcelDto;
import com.zygh.lz.vo.StatisticsVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface SignMapper extends BaseMapper<Sign> {
    int deleteByPrimaryKey(Integer id);

    int insert(Sign record);

    int insertSelective(Sign record);

    Sign selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Sign record);

    int updateByPrimaryKey(Sign record);

    //根据警号和时间获取该警员的签到信息
    List<Sign> findSignInfoByTel(String staffnum);


    List<Sign> findSignInfoByState(String staffnum);


    Sign findSignIn(@Param("policeNumber") String policeNumber,
                    @Param("comment") String comment);

    //查询最后一条签到信息
    Integer findSignInfoByEnd();

    //查询签退的那条记录
    Sign findSignInfoByQt(Sign sign);

    int countByrwmc(@Param("rwmc") String rwmc, @Param("battalion") String battalion,
                    @Param("stafftype") String stafftype, @Param("detachment") String detachment);

    int countQTSD(@Param("battalion") String battalion,
                  @Param("stafftype") String stafftype, @Param("detachment") String detachment);

//    int countYxByrwmc(@Param("rwmc") String rwmc, @Param("battalion") String battalion,
//                      @Param("stafftype") String stafftype, @Param("detachment") String detachment);

    List<Integer> selectNowId(String battalion);

    int countSpecial(@Param("battalion") String battalion, @Param("stafftype") String stafftype);

    List<HashMap> findOnlineUser(String battalion);

    int countXareaByTime(@Param("rwmc") String rwmc, @Param("battalion") String battalion,
                         @Param("startTime") String startTime, @Param("endTime") String endTime,
                         @Param("stafftype") String stafftype, @Param("detachment") String detachment);

    int countYXByTime(@Param("rwmc") String rwmc, @Param("battalion") String battalion,
                      @Param("startTime") String startTime, @Param("endTime") String endTime,
                      @Param("stafftype") String stafftype, @Param("detachment") String detachment);

    //当前民警已经签到 未签退的岗位
    List<HashMap> findPostStatus(@Param("warningsignal") String warningsignal,
                                 @Param("comment") String comment);

    //强制签退
    int signOutById(@Param("id") String id, @Param("nowTime") String nowTime, @Param("gpsqtx") String gpsqtx, @Param("gpsqty") String gpsqty);

    List<String> onlineYesterday(@Param("period") String period, @Param("battalion") String battalion);

    List<String> findZdByBattalion(@Param("period") String period, @Param("battalion") String battalion);

    List<String> findIdByName(@Param("rwmc") String rwmc, @Param("startTime") String startTime, @Param("endTime") String endTime);

    //强制签退
    int signOutByName(@Param("rwmc") String rwmc, @Param("nowTime") String nowTime, @Param("startTime") String startTime, @Param("endTime") String endTime);

    //签到签退列表
    List<Sign> findSignList(@Param("warningsignal") String warningsignal,
                            @Param("starttime") String starttime,
                            @Param("endtime") String endtime,
                            @Param("sectionId") String sectionId);


    //强制签退列表
    List<Sign> signOuts(@Param("rwmc") String rwmc, @Param("nowTime") String nowTime, @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<Map<String, String>> personSign(@Param("staffId") Integer staffId,
                                         @Param("startDate") String startDate,
                                         @Param("endDate") String endDate);

    //签到天数
    List<Map> signDay(@Param("staffId") Integer staffId,
                      @Param("startDate") String startDate,
                      @Param("endDate") String endDate);

    //签到总班次
    List<Map> personSignComment(@Param("staffId") Integer staffId,
                                @Param("startDate") String startDate,
                                @Param("endDate") String endDate);


    List<Map<String, String>> personSignOne(@Param("staffId") Integer staffId,
                                            @Param("startDate") String startDate,
                                            @Param("endDate") String endDate);


    List<Map> personCount(@Param("staffId") Integer staffId,
                          @Param("startDate") String startDate,
                          @Param("endDate") String endDate);

    List<Map> personCounts(@Param("staffId") Integer staffId,
                           @Param("time") String time);

    List<Map> signDetail(@Param("staffId") Integer staffId,
                         @Param("date") String date);


    Sign findlastByid(Integer id);


    List<Sign> findOnLinker(@Param("battalion") String battalion,
                            @Param("station") String station);

    List<HashMap> OnlineBattalion(@Param("station") String station,
                                  @Param("sectionname") String sectionname);


    List<HashMap> OnlineByBattalion(@Param("station") String station,
                                    @Param("sectionname") String sectionname);

    List<Map> OnlineStaffId(@Param("station") String station,
                            @Param("sectionname") String sectionname);

    List<HashMap<String, Object>> OnlinePersonnel(Integer sectionid);

    List<Map> findSignByNum(String SignNum);

    List<Map> findSignByNum1(String SignNum);

    List<Map> findSignByNum2(String SignNum);

    /**
     * ===========================================================
     * 当班在线警力
     * @return
     */
    /**
     * 在线岗位
     *
     * @param station 岗位类型
     * @return
     */
    List<Map<String, Object>> findOnLineSign(@Param("station") String station,
                                             @Param("battalion") String battalion);

    List<Map> findOnLineStrength(@Param("station") String station,
                                 @Param("assignmentid") Integer assignmentid,
                                 @Param("battalion") String battalion,
                                 @Param("stafftype") String stafftype);


    List<Map<String, Object>> findOnLinePeople(@Param("station") String station,
                                               @Param("battalion") String battalion);


    List<Map> OnlineSign(String battalion);


    List<Map<String, Object>> OnlineStaff(@Param("battalion") String battalion);

    /**
     * 昨日在线所有警力
     *
     * @param battalion
     * @return
     */
    List<Map> yesterdayStrength(@Param("battalion") String battalion,
                                @Param("shiftop") String shiftop);


    List<Map> thatVeryDayStrength(@Param("battalion") String battalion,
                                  @Param("shiftop") String shiftop);


    /**
     * 昨日在线所有大队
     *
     * @param battalion
     * @return
     */
    List<Map> yesterdayBranch(String battalion);

    /**
     * 昨日在线所有b班次
     *
     * @param battalion
     * @return
     */
    List<Map> yesterdayClasses(String battalion);

    /**
     * 昨日签到岗位
     *
     * @return
     */
    List<Map> yesterdaySignStation(@Param("staffid") String staffid,
                                   @Param("shiftop") String shiftop);

    /**
     * 昨日在线所有大队
     *
     * @param battalion
     * @return
     */
    List<Map> thatVeryDayBranch(String battalion);

    /**
     * 昨日在线所有b班次
     *
     * @param battalion
     * @return
     */
    List<Map> thatVeryDayClasses(String battalion);

    /**
     * 昨日签到岗位
     *
     * @return
     */
    List<Map> thatVeryDaySignStation(@Param("staffid") String staffid,
                                     @Param("shiftop") String shiftop);


    /**
     * 签到数=正常签到数（高峰岗大于30分钟，其他大于2小时，包含迟到早退的签到；只要达到时长都算签到数）
     * ======================================签到统计====================================================
     */

    /**
     * 按照大队岗位、时间、班次统计 签到数
     *
     * @param sectionId 大队id
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param shiftop   班次
     * @return List<Map>
     */

    List<Map> signInAfew(@Param("sectionId") Integer sectionId,
                         @Param("startTime") String startTime,
                         @Param("endTime") String endTime,
                         @Param("modeCode") Integer modeCode,
                         @Param("comment") Integer comment);


    List<Map> signInAfewLochu(@Param("sectionId") Integer sectionId,
                              @Param("startTime") String startTime,
                              @Param("endTime") String endTime,
                              @Param("shiftop") Integer shiftop,
                              @Param("comment") Integer comment);


    //签到的中队
    List<Map<String, Object>> signInAfewLochus(@Param("sectionDId") Integer sectionDId,
                                               @Param("sectionId") Integer sectionId,
                                               @Param("startTime") String startTime,
                                               @Param("endTime") String endTime,
                                               @Param("shiftop") Integer shiftop,
                                               @Param("comment") Integer comment);


    //签到中队的人员信息
    List<Map> signInStaffLochus(@Param("sectionId") Integer sectionId,
                                @Param("startTime") String startTime,
                                @Param("endTime") String endTime,
                                @Param("shiftop") Integer shiftop,
                                @Param("comment") Integer comment);

    /**
     * 按照中队岗位、时间、班次统计 签到数
     *
     * @param sectionId 大队id
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param shiftop   班次
     * @return List<Map>
     */

    List<Map> signInAfewLeader(@Param("sectionId") Integer sectionId,
                               @Param("startTime") String startTime,
                               @Param("endTime") String endTime,
                               @Param("shiftop") Integer shiftop,
                               @Param("comment") Integer comment);

    //按照岗位统计签到统计详情   签到包含大队
    List<Map> signInNumber(@Param("sectionId") Integer sectionId,
                           @Param("startTime") String startTime,
                           @Param("endTime") String endTime,
                           @Param("shiftop") Integer shiftop,
                           @Param("comment") Integer comment);

    List<Map> signInNumberLeader(@Param("sectionId") Integer sectionId,
                                 @Param("startTime") String startTime,
                                 @Param("endTime") String endTime,
                                 @Param("shiftop") Integer shiftop);


    List<Map> signInStation(@Param("staffid") Integer staffid,
                            @Param("startTime") String startTime,
                            @Param("endTime") String endTime,
                            @Param("shiftop") Integer shiftop,
                            @Param("comment") Integer comment);


    List<Map> SignInExport(@Param("sectionId") Integer sectionId,
                           @Param("startTime") String startTime,
                           @Param("endTime") String endTime,
                           @Param("shiftop") Integer shiftop,
                           @Param("sectionzId") Integer sectionzId);


    /**
     * 根据岗位统计人
     *
     * @param sectionId 大队
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param station   岗位
     * @param comment   勤务类型（1：日常勤务 2：特殊勤务）
     * @return List<Map>
     */
    List<Map> SignInStationInfo(@Param("sectionId") Integer sectionId,
                                @Param("startTime") String startTime,
                                @Param("endTime") String endTime,
                                @Param("station") String station,
                                @Param("comment") Integer comment);

    /**
     * 根据岗位统计中队下签到人员
     *
     * @param sectionId 中队id
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @param station   岗位
     * @param comment   勤务类型（1：日常勤务 2：特殊勤务）
     * @return
     */
    List<Map> SignInStationLochus(@Param("sectionId") Integer sectionId,
                                  @Param("startTime") String startTime,
                                  @Param("endTime") String endTime,
                                  @Param("station") String station,
                                  @Param("comment") Integer comment);


    List<Map> OnLineInNum(@Param("sectionId") Integer sectionId);

    List<Map> OnLineInNumBymode(@Param("sectionId") Integer sectionId);


    List<Map> OnLineByLochus(@Param("sectionId") Integer sectionId);

    List<Map> OnLineByLochusBymode(@Param("sectionId") Integer sectionId);

    List<Map> SignInNumBySection(@Param("sectionId") Integer sectionId,
                                 @Param("startTime") String startTime,
                                 @Param("endTime") String endTime,
                                 @Param("staffname") String staffname);


    List<Map> OnLineInNumLochus(@Param("sectionId") Integer sectionId,
                                @Param("startTime") String startTime,
                                @Param("endTime") String endTime,
                                @Param("staffname") String staffname);


    List<Map> SignInNum(@Param("sectionId") Integer sectionId,
                        @Param("startTime") String startTime,
                        @Param("endTime") String endTime);

    List<Map> SignInNums(@Param("sectionId") Integer sectionId,
                         @Param("time") String time);


    List<Map> auxiliarySignInNum(@Param("sectionId") Integer sectionId,
                                 @Param("time") String time);


    List<Map<String, Object>> SignInNumByStaff(Integer staffid);


    //中队下签到数（按照班次统计）
    List<Map> SignInNumLochus(@Param("sectionId") Integer sectionId,
                              @Param("startTime") String startTime,
                              @Param("endTime") String endTime);

    List<Map> auxiliarySignInNumLochus(@Param("sectionId") Integer sectionId,
                                       @Param("time") String time);


    List<Map> SignInSection(@Param("sectionId") Integer sectionId,
                            @Param("time") String time);

    //签到统计各大队部门统计
    List<Map<String, Object>> SignInLochus(@Param("sectionId") Integer sectionId,
                                           @Param("time") String time);

    //各个大队其余部门统一归属到机关
    List<Map> SignInByLochus(@Param("sectionId") Integer sectionId,
                             @Param("type") String type);


    List<Map> OnlineAll();


    /**
     * =====================================签到统计==================================================
     */
    //大队根据班次日常
    List<Map<String, Object>> signInNumbers(@Param("sectionId") Integer sectionId,
                                            @Param("startTime") String startTime,
                                            @Param("endTime") String endTime,
                                            @Param("shiftop") Integer shiftop,
                                            @Param("comment") Integer comment);

    //大队根据班次特殊
    List<Map<String, Object>> signInSpecialNumbers(@Param("sectionId") Integer sectionId,
                                                   @Param("startTime") String startTime,
                                                   @Param("endTime") String endTime,
                                                   @Param("shiftop") Integer shiftop,
                                                   @Param("comment") Integer comment);

    //大队根据岗位查询
    List<Map<String, Object>> signInSpecialDetail(@Param("sectionId") Integer sectionId,
                                                  @Param("startTime") String startTime,
                                                  @Param("endTime") String endTime,
                                                  @Param("station") String station,
                                                  @Param("comment") Integer comment);


    //中队根据班次特殊
    List<Map<String, Object>> signInSpecialNumberLochus(@Param("sectionDId") Integer sectionDId,
                                                        @Param("sectionId") Integer sectionId,
                                                        @Param("startTime") String startTime,
                                                        @Param("endTime") String endTime,
                                                        @Param("shiftop") Integer shiftop,
                                                        @Param("comment") Integer comment);

    //中队岗位查询
    List<Map<String, Object>> signInSpecialDetailLochus(@Param("sectionDId") Integer sectionDId,
                                                        @Param("sectionId") Integer sectionId,
                                                        @Param("startTime") String startTime,
                                                        @Param("endTime") String endTime,
                                                        @Param("station") String station,
                                                        @Param("comment") Integer comment);

    List<Map> OnlineSigns(String battalion);


    /**
     * ========================================领导驾驶舱=============================================
     */

    //在线大队
    List<Map> findOnlineSection(Integer id);

    //在线民警辅警数
    List<Map> findStaffByState(@Param("type") String type,
                               @Param("id") Integer id);

    /**
     * 获取各大队签到数量
     *
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @return 签到数量
     */
    List<Map<String, String>> countSignedOfDSectionAndStaffType(@Param("startTime") String startTime,
                                                                @Param("endTime") String endTime);

    /**
     * 获取大队下中队签到数量
     *
     * @param sectionId 部门id
     * @param startTime 开始时间
     * @param endTime   结束时间
     * @return 签到数量
     */
    List<Map<String, String>> countSignedOfZSectionAndStaffType(@Param("sectionId") Integer sectionId,
                                                                @Param("startTime") String startTime,
                                                                @Param("endTime") String endTime);

    //在线民警辅警数量
    @Select("<script> " +
            "SELECT s.warningsignal FROM sign s LEFT JOIN staff sf ON s.warningsignal = sf.staff_num " +
            "<where> state = 1 AND stafftype = #{type} " +
            "<if test = 'sectionName != null'>" +
            " AND  sectionname LIKE CONCAT('%',#{sectionName},'%')" +
            "</if>" +
            "group by s.warningsignal" +
            "</where>" +
            "</script>")
    List<String> findOnlineSignByType(@Param("sectionName") String sectionName,
                                      @Param("type") String type);


    //根据大队和查询在线民警辅警人员
    List<Map<String, Object>> onlineSignByTypes(@Param("battalion") String battalion,
                                                @Param("stafftype") String stafftype);


    //当班累计在线
    List<Map<String, Object>> accumulative(@Param("type") String type,
                                           @Param("comment") String comment,
                                           @Param("sectionId") Integer sectionId);

    List<Map<String, Object>> selectRecordSign(Integer id);


    //支队当日总警力()
    int findTotalForces(@Param("sectionId") Integer sectionId,
                        @Param("startTime") String startTime,
                        @Param("endTime") String endTime,
                        @Param("isCheck") Integer isCheck);

    //每天总警力
    List<Map<String, Object>> findTotalForcesByWeek(@Param("sectionId") Integer sectionId,
                                                    @Param("startTime") String startTime,
                                                    @Param("endTime") String endTime,
                                                    @Param("isCheck") Integer isCheck);


    int findTotalPolice(@Param("sectionId") Integer sectionId,
                        @Param("isCheck") Integer isCheck);

    int findTotalTime(@Param("sectionId") Integer sectionId,
                      @Param("startTime") String startTime,
                      @Param("endTime") String endTime);

    //用于计算市场
    @Select("SELECT signnum,signintime,signouttime FROM sign " +
            "WHERE signintime BETWEEN #{startTime} AND #{endTime} AND staffid = #{id}")
    List<Map<String, Object>> findSignById(@Param("id") Integer id,
                                           @Param("startTime") String startTime,
                                           @Param("endTime") String endTime);

    @Select("select sf.staff_photo as staffPhoto, staffid,sc.section_pid as sectionPid,warningsignal as warningSignal,sectionName as sectionName,staffname as name ," +
            " sum(timestampdiff(MINUTE,signintime, if(signouttime != '',signouttime,now() )) ) as duration from sign sg left join section sc on sc.sys_section_id = sg.sectionid " +
            " left join staff sf on sf.sys_staff_id = sg.staffid " +
            " where signintime between #{startTime} and #{endTime} " +
            " and timestampdiff(MINUTE,signintime, if(signouttime != '',signouttime,now() )) != 0 " +
            " group by  sg.staffid  " +
            " order by duration desc")
    List<SignStatistics> findTime(ExcelDto excelDto);

    @Select("<script>" +
            " select count(distinct(warningsignal)) as num from sign s " +
            "  LEFT JOIN staff sf ON s.warningsignal = sf.staff_num " +
            "   LEFT JOIN section sc ON sc.sys_section_id = s.sectionid " +
            " where state = 1 and comment = 1" +
            " <if test='sectionDid!=null'>" +
            "   AND sc.section_pid = #{sectionDid} " +
            " </if>" +
            "  </script>")
    StatisticsVo currentPolice(@Param("sectionDid") Integer sectionDid);

    @Select("<script> select count(distinct(warningsignal)) as totalNum from sign s" +
            "  LEFT JOIN staff sf ON s.warningsignal = sf.staff_num " +
            "   LEFT JOIN section sc ON sc.sys_section_id = s.sectionid " +
            " where signintime between #{startTime} and #{endTime} and comment = 1 " +
            "            <if test=\"sectionDid != null and sectionDid !=''\">\n" +
            "                AND sc.section_pid = #{sectionDid}\n" +
            "            </if>" +
            "</script>")
    StatisticsVo todayPolice(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("sectionDid") Integer sectionDid);

    @Select("select count(distinct(warningsignal)) as num from sign where signintime between #{startTime} and #{endTime} and state = 1 and comment = 2")
    StatisticsVo specialCurrentPolice(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select count(distinct(warningsignal)) as totalNum from sign where signintime between #{startTime} and #{endTime} and comment =2 ")
    StatisticsVo specialTodayPolice(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("<script>" +
            " select count(distinct(warningsignal)) as totalNum from sign where " +
            " signintime between #{startTime} and #{endTime} and comment =2 and state = 1 " +
            " <if test='sectionId != null'>" +
            " and sectionid = #{sectionId}" +
            " </if> " +
            " <if test='modeCode != null'>" +
            " and mode_code = #{modeCode}" +
            "</if>" +
            " </script>")
    Integer selectByMode(@Param("sectionId") Integer sectionDid, @Param("modeCode") Integer modeCode, @Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("<script> select count(distinct(warningsignal)) as totalNum from sign s " +
            " LEFT JOIN staff sf ON s.warningsignal = sf.staff_num " +
            "  LEFT JOIN section sc ON sc.sys_section_id = s.sectionid " +
            " where signintime between #{yesterdayStart} and #{yesterdayEnd} " +
            " and comment = 1 " +
            " and state = 1 " +
            "            <if test=\"sectionDid != null and sectionDid !=''\">\n" +
            "                AND sc.section_pid = #{sectionDid}\n" +
            "            </if>" +
            "</script>")
    int yesterdayPolice(@Param("yesterdayStart") String yesterdayStart, @Param("yesterdayEnd") String yesterdayEnd, @Param("sectionDid") Integer sectionDid);

    @Select("<script>" +
            " select mode_code,count(1) as countSize from sign " +
            "<where>" +
            "<if test='sectionId != null'>" +
            " and sectionid in ( select sys_section_id from section where section_pid = #{sectionId} ) " +
            "</if>" +
            "<if test='startTime != null'>" +
            " and signintime &gt;= #{startTime} " +
            "</if>" +
            "<if test='endTime != null'>" +
            " and signintime &lt;= #{endTime}" +
            "</if>" +
            "<if test='shiftop != null'>" +
            " and shiftop = #{shiftop}" +
            "</if>" +
            " group by mode_code" +
            "</where>" +
            "</script>")
    List<Map<String, Object>> signInDetail2(@Param("sectionId") Integer sectionId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("shiftop") Integer shiftop);

    @Select("<script>" +
            " select count(1) as countSize from sign " +
            "<where> " +
            " comment = 2 " +
            "<if test='sectionId != null'>" +
            " and sectionid in ( select sys_section_id from section where section_pid = #{sectionId} ) " +
            "</if>" +
            "<if test='startTime != null'>" +
            " and signintime &gt;= #{startTime} " +
            "</if>" +
            "<if test='endTime != null'>" +
            " and signintime &lt;= #{endTime}" +
            "</if>" +
            "<if test='shiftop != null'>" +
            " and shiftop = #{shiftop}" +
            "</if>" +

            "</where>" +
            "</script>")
    Integer signInDetail3(@Param("sectionId") Integer sectionId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("shiftop") Integer shiftop);

    @Select("    <script>     SELECT  count(DISTINCT(warningsignal))  FROM sign s LEFT JOIN staff sf ON s.warningsignal = sf.staff_num LEFT JOIN section sc ON\n" +
            "        sf.sys_section_id = sc.sys_section_id  " +
            " <where>" +
            " signintime BETWEEN #{startime} AND #{endTime} " +
            " <if test='sectionId != null'>" +
            " and sc.section_pid = #{sectionId} " +
            " </if>" +
            "</where>" +
            "  " +
            "</script> ")
    Integer signIn(@Param("sectionId") Integer sectionId, @Param("startime") String startime, @Param("endTime") String endTime);

    @Select("<script>" +
            " select count(distinct(warningsignal)) as totalNum from sign s " +
            " LEFT JOIN staff sf ON s.warningsignal = sf.staff_num " +
            "  LEFT JOIN section sc ON sc.sys_section_id = s.sectionid " +
            "where signintime between #{startTime} and #{endTime} and comment =2  " +
            " <if test='sectionId != null' >" +
            "                AND sc.section_pid = #{sectionId} " +
            "            </if>" +
            "</script>")
    StatisticsVo specialTodayPoliceBySecion(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("sectionId") Integer sectionId);

    @Select("SELECT COUNT(*) as signPostNum FROM (SELECT * FROM sign WHERE signintime  like concat(#{today},'%')  GROUP BY assignmentid) si " +
            " LEFT JOIN section sc ON si.sectionid = sc.sys_section_id WHERE sc.section_pid = #{sectionDid} OR si.sectionid = #{sectionDid} ")
    StatisticsVo order(@Param("sectionDid") Integer sectionDid,
                       @Param("today") String today);

    @Select("<script> SELECT COUNT(*) as signPostNum FROM (SELECT * FROM xarea WHERE  whether = 1 " +
            " <if test='postCode != null'> " +
            "  and post_code in " +
            "<foreach  item=\"item\" collection=\"postCode\" index=\"index\"  open=\"(\" separator=\",\" close=\")\"> " +
            " #{item} " +
            "</foreach> " +
            " </if> " +
            " AND detachment IS not NULL ) a " +
            "INNER JOIN (SELECT * FROM sign WHERE signintime like concat(#{today},'%') GROUP BY assignmentid) b ON  a.id = b.assignmentid  " +
            "LEFT JOIN section sc on b.sectionid=sc.sys_section_id <where> " +
            " <if test = 'sectionDid != null'> " +
            "  sc.section_pid = #{sectionDid} OR b.sectionid = #{sectionDid}" +
            "</if>" +
            " </where>" +
            " </script> ")
    StatisticsVo order1(@Param("sectionDid") Integer sectionDid,
                        @Param("today") String today,
                        @Param("postCode") int[] postCode);

    @Select("<script> SELECT * FROM (SELECT * FROM xarea WHERE  whether = 1 " +
            " <if test='postCode != null'> " +
            "  and post_code in " +
            "<foreach  item=\"item\" collection=\"postCode\" index=\"index\"  open=\"(\" separator=\",\" close=\")\"> " +
            " #{item} " +
            "</foreach> " +
            " </if> " +
            " AND detachment IS not NULL ) a " +
            "INNER JOIN (SELECT * FROM sign WHERE signintime like concat(#{today},'%') GROUP BY assignmentid) b ON  a.id = b.assignmentid  " +
            "LEFT JOIN section sc on b.sectionid=sc.sys_section_id <where> " +
            " <if test = 'sectionDid != null'> " +
            "  sc.section_pid = #{sectionDid} OR b.sectionid = #{sectionDid}" +
            "</if>" +
            " </where>" +
            " </script> ")
    List<Map<String, Object>> order2(@Param("sectionDid") Integer sectionDid,
                                     @Param("today") String today,
                                     @Param("postCode") int[] postCode);

    List<Sign> findSignListByCfstatus();

    @Select("select assignmentid\n" +
            "      from sign\n" +
            "      where signintime between DATE_FORMAT(now(), '%Y-%m-%d') and DATE_FORMAT(now(), '%Y-%m-%d 23:59:59') and comment = #{type}")
    List<Integer> getTodaySignInPostId(Integer type);


    String todayEquipageNumber(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("sectionDid") Integer sectionDid);

    List<Map<String, Object>> selectSignPost(@Param("sectionDid") Integer sectionDid, @Param("status") Integer status);

    Integer countSpecialSignPost(@Param("sectionDid") Integer sectionDid, @Param("status") Integer status);

    Integer policeSignCount(@Param("sectionDid") Integer sectionDid, @Param("status") Integer status);

    Integer countSingPostNum(@Param("sectionDid") Integer sectionDid, @Param("status") Integer status);
}